<template>
  <div>
    <div class="card-header">
      <div class="header-icon">
        <img :src="getIconFn()" />
      </div>
      <div class="header-word">{{ projectTitle }}</div>
    </div>
    <div>
      <el-scrollbar height="690px">
        <el-card
          shadow="hover"
          @click="onCard(item)"
          class="body-card"
          v-for="(item, index) in projectList"
          :key="index"
        >
          <div class="body-top" v-if="item.flag">
            <div class="top-icon">已置顶</div>
          </div>
          <div class="body-top-copy" v-if="!item.flag"></div>
          <div class="body-header">{{ item.title }}</div>
          <div class="body-word">
            <span>开展日期：</span>
            <span>{{ item.time }}</span>
          </div>
          <div class="body-word">
            <span>总数：</span>
            <span class="number-color">{{ item.total }}</span>
            <span>提审：</span>
            <span class="number-color">{{ item.arraign }}</span>
            <span>已完成：</span>
            <span class="number-color">{{ item.completed }}</span>
          </div>
          <div class="body-word">
            <span>当前审批处理人：</span>
            <span>{{ item.approver }}</span>
          </div>
        </el-card>
      </el-scrollbar>
    </div>
  </div>
</template>

<script>
import timepiece from '@/assets/images/workbench-homepage/timepiece.png';
import work from '@/assets/images/workbench-homepage/work.png';
import bulletin from '@/assets/images/workbench-homepage/bulletin.png';
import download from '@/assets/images/workbench-homepage/download.png';
import wrench from '@/assets/images/workbench-homepage/wrench.png';
export default {
  props: {
    projectList: Array,
    projectImg: String,
    projectTitle: String,
  },
  methods: {
    getIconFn() {
      if (this.projectImg === '1') {
        return timepiece;
      }
      if (this.projectImg === '2') {
        return wrench;
      }
      if (this.projectImg === '3') {
        return work;
      }
      if (this.projectImg === '4') {
        return bulletin;
      }
      if (this.projectImg === '5') {
        return download;
      }
    },
    onCard(item) {
      console.log('点击', item.title);
      if (item.title === '项目资料') {
        this.$router.push({
          path: '/project-control/project-work/index-home',
        });
      }
      this.$emit('onCard', item.title);
    },
  },
};
</script>

<style lang="scss" scoped>
.card-header {
  height: 40px;
  width: 100%;
  margin: 22px 0 24px 0;
  padding-left: 24px;
  box-sizing: border-box;
  display: flex;
  .header-icon {
    width: 40px;
    height: 40px;
    margin-right: 16px;
  }
  .header-word {
    width: 64px;
    height: 23px;
    font-weight: 700;
    color: #25292c;
    font-size: 16px;
    padding-top: 10px;
  }
}
.body-card {
  cursor: pointer;
  width: 328px;
  height: 160px;
  background: #f6f9ff;
  border-radius: 2px 2px 2px 2px;
  border: 1px solid #d9dce4;
  margin: 0 16px 16px 16px;
  .body-top {
    width: 100%;
    height: 17px;
    display: flex;
    justify-content: end;
    .top-icon {
      width: 54px;
      height: 17px;
      background-image: url('@/assets/images/workbench-homepage/rectangle.png');
      font-size: 12px;
      color: #fff;
      padding-left: 15px;
      box-sizing: border-box;
    }
  }
  .body-top-copy {
    width: 100%;
    height: 17px;
  }
  .body-header {
    font-size: 14px;
    font-weight: 700;
    margin-left: 15px;
    margin-bottom: 16px;
  }
  .body-word {
    color: #50565d;
    font-size: 14px;
    font-weight: 400;
    margin-left: 16px;
    margin-bottom: 8px;
    .number-color {
      color: #2e72ef;
      margin-right: 20px;
    }
  }
}
</style>
